<template>
  <div class="bg-light">
    <!-- 头部 -->
    <div class="header d-flex align-items-center">
      <router-link to="/math" class="text-dark">
        <i class="bi bi-chevron-left fs-4"></i>
      </router-link>
      <h5 class="mb-0 mx-auto">历年真题</h5>
    </div>

    <!-- 年份卡片列表 -->
    <router-link 
      v-for="year in yearCards" 
      :key="year.year"
      :to="`/math/real/practice?year=${year.year}`" 
      class="text-decoration-none"
    >
      <div class="year-card">
        <h6 class="year-title">
          <span>
            <i class="bi bi-calendar-fill"></i>
            {{ year.year }}年真题
          </span>
          <span :class="getAccuracyBadgeClass(year.accuracy)">
            正确率 {{ year.accuracy }}%
          </span>
        </h6>
        <div class="progress">
          <div 
            class="progress-bar" 
            :style="`width: ${year.progress}%`"
          ></div>
        </div>
        <div class="stats-info">
          <span>已完成{{ year.progress }}%</span>
          <span>{{ year.completedCount }}/{{ year.totalCount }}题</span>
        </div>
        <div class="stats-detail">
          <div class="stats-item">
            <div class="stats-value">{{ year.completedCount }}</div>
            <div class="stats-label">已做题数</div>
          </div>
          <div class="stats-item">
            <div class="stats-value">{{ year.correctCount }}</div>
            <div class="stats-label">答对题数</div>
          </div>
          <div class="stats-item">
            <div class="stats-value">{{ year.wrongCount }}</div>
            <div class="stats-label">错题数</div>
          </div>
          <div class="stats-item">
            <div class="stats-value">{{ year.remainingCount }}</div>
            <div class="stats-label">剩余题数</div>
          </div>
        </div>
      </div>
    </router-link>
  </div>
</template>

<script>
export default {
  name: 'MathRealView',
  data() {
    return {
      yearCards: [
        {
          year: 2024,
          accuracy: 85,
          progress: 80,
          completedCount: 20,
          totalCount: 25,
          correctCount: 17,
          wrongCount: 3,
          remainingCount: 5
        },
        {
          year: 2023,
          accuracy: 90,
          progress: 100,
          completedCount: 25,
          totalCount: 25,
          correctCount: 22,
          wrongCount: 3,
          remainingCount: 0
        }
      ]
    }
  },
  methods: {
    getAccuracyBadgeClass(accuracy) {
      return {
        'accuracy-badge': true,
        'low': accuracy < 60,
        'medium': accuracy >= 60 && accuracy < 80,
        'high': accuracy >= 80
      }
    }
  }
}
</script>

<style scoped>
.header {
  padding: 15px;
  background: white;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.year-card {
  background: white;
  margin: 15px;
  padding: 20px;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.year-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.year-title {
  color: #40E0D0;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress {
  height: 6px;
  margin: 15px 0;
}

.progress-bar {
  background-color: #40E0D0;
}

.stats-info {
  display: flex;
  justify-content: space-between;
  color: #666;
  font-size: 0.9rem;
  margin-top: 10px;
}

.stats-detail {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #eee;
}

.stats-item {
  text-align: center;
}

.stats-value {
  font-size: 1.2rem;
  color: #40E0D0;
  font-weight: bold;
}

.stats-label {
  font-size: 0.8rem;
  color: #666;
}

.accuracy-badge {
  background: #e9ecef;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
}

.accuracy-badge.low {
  background: #FFE4E1;
  color: #dc3545;
}

.accuracy-badge.medium {
  background: #FFF3CD;
  color: #856404;
}

.accuracy-badge.high {
  background: #E8F5E9;
  color: #28a745;
}
</style> 